<?php

/**
 * @category controller
 * @name $Customers
 * @package admin
 * @author HungPV <phamvanhung0818@gmail.com>
 */
class Customers extends MX_Controller {

    function __construct() {
        parent::__construct();
    }

    function index($page = 0) {
        $customer = new Customer();
        $perpage = 10;
        $total = $customer->count();

        if ($total / $perpage > intval($total / $perpage)) {
            $total_page = intval($total / $perpage) + 1;
        } else {
            $total_page = intval($total / $perpage);
        }

        $paging = $this->config->item('paging');
        $paging['per_page'] = 1;
        $paging['total_rows'] = $total_page;
        $paging['cur_page'] = $page;
        $paging['base_url'] = base_url() . 'admin/customers/index/';
        $this->pagination->initialize($paging);
        $data['list_link'] = $this->pagination->create_links();
        
        $customer->order_by('id', 'DESC');
        $customer->get_paged($page + 1, $perpage);

        $data['customers'] = $customer;
        $data['view'] = 'customers_index';
        $this->load->view('admin_theme/template', $data);
    }

    function edit($id = 0) {
        
    }

    function delete() {
        $id = $this->input->post('id');
        $customer = new Customer();
        $customer->where('id', $id)->get()->delete();
        
    }

}

?>